package com.imooc.user.repository.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.imooc.user.repository.entity.TUserCenterUser;
import com.imooc.user.repository.mapper.TUserCenterUserMapper;
import com.imooc.user.repository.service.ITUserCenterUserService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* <br>
* <b>功能：</b>用户表 服务实现类<br>
* <b>作者：</b>Tim<br>
* <b>日期：</b>2023<br>
*/
@Service
public class TUserCenterUserServiceImpl extends ServiceImpl<TUserCenterUserMapper, TUserCenterUser> implements ITUserCenterUserService {

    /**
     * 根据群组id查找学生
     * @param groupId
     * @return
     */
    public List<TUserCenterUser> getUsersByGroupId(String groupId){
        LambdaQueryWrapper<TUserCenterUser> queryWrapper = new LambdaQueryWrapper(TUserCenterUser.class);
        queryWrapper.eq(TUserCenterUser::getGroupId, groupId);
        List<TUserCenterUser> tUserCenterUsers = getBaseMapper().selectList(queryWrapper);
        return tUserCenterUsers;
    }

    @Override
    public List<TUserCenterUser> getUsersByGroupIds(List<String> groupIds) {
        LambdaQueryWrapper<TUserCenterUser> queryWrapper = new LambdaQueryWrapper(TUserCenterUser.class);
        queryWrapper.in(TUserCenterUser::getGroupId, groupIds);
        return getBaseMapper().selectList(queryWrapper);
    }

}
